import { useState, useEffect } from "react";
import { getChannels } from "../apis/article";
// 1.创建一个use打头的函数
function useChannel() {
    const [channelsList, setChannelsList] = useState([])
    useEffect(() => {
        return async () => {
            const res = await getChannels()
            console.log(res);
            setChannelsList(res.data.data.channels)
        }
    }, [])
    // 2.在函数中封装业务逻辑，并返回出组件中要用到的状态
    return { channelsList };
}
export { useChannel }